home *** CD-ROM | disk | FTP | other *** search
/ PC go! 2008 April / PCgo 2008-04 (DVD).iso / interface / contents / demoversionen_3846 / 13664 / files / Data1.cab / frmconverter.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2001-09-22  |  10.6 KB  |  352 lines

  1. VERSION 5.00
  2. Begin VB.Form frmConvert 
  3.    Caption         =   "TurboCAD SDK file converter"
  4.    ClientHeight    =   6960
  5.    ClientLeft      =   60
  6.    ClientTop       =   345
  7.    ClientWidth     =   11415
  8.    LinkTopic       =   "Form1"
  9.    MaxButton       =   0   'False
  10.    MinButton       =   0   'False
  11.    ScaleHeight     =   6960
  12.    ScaleWidth      =   11415
  13.    StartUpPosition =   3  'Windows Default
  14.    Begin VB.Timer Timer1 
  15.       Enabled         =   0   'False
  16.       Interval        =   500
  17.       Left            =   5040
  18.       Top             =   5760
  19.    End
  20.    Begin VB.ComboBox Combo2 
  21.       Height          =   315
  22.       Left            =   6960
  23.       Style           =   2  'Dropdown List
  24.       TabIndex        =   18
  25.       Top             =   5280
  26.       Width           =   4215
  27.    End
  28.    Begin VB.ComboBox Combo1 
  29.       Height          =   315
  30.       ItemData        =   "frmConverter.frx":0000
  31.       Left            =   1320
  32.       List            =   "frmConverter.frx":0002
  33.       MousePointer    =   1  'Arrow
  34.       Style           =   2  'Dropdown List
  35.       TabIndex        =   17
  36.       Top             =   5280
  37.       Width           =   4215
  38.    End
  39.    Begin VB.DriveListBox Drive2 
  40.       Height          =   315
  41.       Left            =   6000
  42.       TabIndex        =   7
  43.       Top             =   1080
  44.       Width           =   2415
  45.    End
  46.    Begin VB.DirListBox Dir2 
  47.       Height          =   2565
  48.       Left            =   6000
  49.       TabIndex        =   6
  50.       ToolTipText     =   "Select a directory where converted files will be placed."
  51.       Top             =   1680
  52.       Width           =   2415
  53.    End
  54.    Begin VB.FileListBox File2 
  55.       Height          =   2430
  56.       Left            =   8640
  57.       Pattern         =   "*.tcw"
  58.       TabIndex        =   5
  59.       Top             =   1680
  60.       Width           =   2415
  61.    End
  62.    Begin VB.FileListBox File1 
  63.       Height          =   2430
  64.       Left            =   3000
  65.       MultiSelect     =   2  'Extended
  66.       Pattern         =   "*.tcw"
  67.       TabIndex        =   4
  68.       ToolTipText     =   "A list of files to be converted."
  69.       Top             =   1680
  70.       Width           =   2415
  71.    End
  72.    Begin VB.DirListBox Dir1 
  73.       Height          =   2565
  74.       Left            =   360
  75.       TabIndex        =   3
  76.       ToolTipText     =   "Select a directory containing files for conversion."
  77.       Top             =   1680
  78.       Width           =   2415
  79.    End
  80.    Begin VB.DriveListBox Drive1 
  81.       Height          =   315
  82.       Left            =   360
  83.       TabIndex        =   2
  84.       Top             =   1080
  85.       Width           =   2415
  86.    End
  87.    Begin VB.CommandButton Close 
  88.       Caption         =   "Close"
  89.       Height          =   495
  90.       Left            =   120
  91.       TabIndex        =   1
  92.       Top             =   6120
  93.       Width           =   1300
  94.    End
  95.    Begin VB.CommandButton Run 
  96.       Caption         =   "Run"
  97.       Height          =   495
  98.       Left            =   3000
  99.       TabIndex        =   0
  100.       ToolTipText     =   "Starts the conversion process."
  101.       Top             =   6120
  102.       Width           =   1300
  103.    End
  104.    Begin VB.Frame Source 
  105.       Caption         =   "Source:"
  106.       Height          =   4215
  107.       Left            =   120
  108.       TabIndex        =   8
  109.       Top             =   720
  110.       Width           =   5415
  111.       Begin VB.Label NFiles1 
  112.          Height          =   375
  113.          Left            =   3960
  114.          TabIndex        =   12
  115.          Top             =   3720
  116.          Width           =   1215
  117.       End
  118.       Begin VB.Label Label1 
  119.          Caption         =   "Total files:"
  120.          Height          =   375
  121.          Left            =   2880
  122.          TabIndex        =   9
  123.          Top             =   3720
  124.          Width           =   855
  125.       End
  126.    End
  127.    Begin VB.Frame Target 
  128.       Caption         =   "Destination:"
  129.       Height          =   4215
  130.       Left            =   5760
  131.       TabIndex        =   10
  132.       Top             =   720
  133.       Width           =   5415
  134.       Begin VB.Label NFiles2 
  135.          Height          =   375
  136.          Left            =   4080
  137.          TabIndex        =   13
  138.          Top             =   3720
  139.          Width           =   1215
  140.       End
  141.       Begin VB.Label Label2 
  142.          Caption         =   "Total files: "
  143.          Height          =   375
  144.          Left            =   2880
  145.          TabIndex        =   11
  146.          Top             =   3720
  147.          Width           =   855
  148.       End
  149.    End
  150.    Begin VB.Label ExportFiltersList 
  151.       Caption         =   "Files of type:"
  152.       Height          =   375
  153.       Left            =   5760
  154.       TabIndex        =   16
  155.       Top             =   5280
  156.       Width           =   975
  157.    End
  158.    Begin VB.Label ImportFiltersList 
  159.       Caption         =   "Files of type:"
  160.       Height          =   375
  161.       Left            =   120
  162.       TabIndex        =   15
  163.       Top             =   5280
  164.       Width           =   975
  165.    End
  166.    Begin VB.Label Label3 
  167.       BorderStyle     =   1  'Fixed Single
  168.       Height          =   375
  169.       Left            =   3000
  170.       TabIndex        =   14
  171.       Top             =   240
  172.       Width           =   8175
  173.    End
  174. Attribute VB_Name = "frmConvert"
  175. Attribute VB_GlobalNameSpace = False
  176. Attribute VB_Creatable = False
  177. Attribute VB_PredeclaredId = True
  178. Attribute VB_Exposed = False
  179. '******************************************************************'
  180. '*                                                                *'
  181. '*                      TurboCAD for Windows                      *'
  182. '*                   Copyright (c) 1993 - 2001                    *'
  183. '*             International Microcomputer Software, Inc.         *'
  184. '*                            (IMSI)                              *'
  185. '*                      All rights reserved.                      *'
  186. '*                                                                *'
  187. '******************************************************************'
  188. Option Explicit
  189. Private Sub Close_Click()
  190.     Unload Me
  191.     Set Drs = Nothing
  192.     Set objApp = Nothing
  193. End Sub
  194. Private Sub Combo1_LostFocus()
  195.     Timer1.Enabled = False
  196.     File1.Pattern = Left((Right(Combo1.Text, 6)), 5)
  197.     File1.Refresh
  198.     NFiles1.Caption = File1.ListCount
  199. End Sub
  200. Private Sub Combo1_GotFocus()
  201.     CurCombo = True
  202.     Timer1.Enabled = True
  203.     CurImportFilter = Combo1.Text
  204. End Sub
  205. Private Sub Combo2_LostFocus()
  206.     Timer1.Enabled = False
  207.     File2.Pattern = Left((Right(Combo2.Text, 6)), 5)
  208.     File2.Refresh
  209.     NFiles2.Caption = File2.ListCount
  210. End Sub
  211. Private Sub Combo2_GotFocus()
  212.     CurCombo = False
  213.     Timer1.Enabled = True
  214.     CurExportFilter = Combo2.Text
  215. End Sub
  216. Private Sub Dir1_Change()
  217.     File1.FileName = Dir1.Path
  218.     File1.Refresh
  219.     NFiles1.Caption = File1.ListCount
  220. End Sub
  221. Private Sub Dir2_Change()
  222.     File2.FileName = Dir2.Path
  223.     File2.Refresh
  224.     NFiles2.Caption = File2.ListCount
  225. End Sub
  226. Private Sub Drive1_Change()
  227.     Dir1.Path = Drive1.Drive
  228.     Dir1.Refresh
  229.     File1.FileName = Dir1.Path
  230.     File1.Refresh
  231.     NFiles1.Caption = File1.ListCount
  232. End Sub
  233. Private Sub Drive2_Change()
  234.     Dir2.Path = Drive2.Drive
  235.     Dir2.Refresh
  236.     File2.FileName = Dir2.Path
  237.     File2.Refresh
  238.     NFiles2.Caption = File2.ListCount
  239. End Sub
  240. Private Sub Form_Load()
  241.    Dim a As Integer
  242.    Set objApp = CreateObject("IMSIGX.Application")
  243.     If objApp Is Nothing Then
  244.         MsgBox "Could not start server.  " & Err.Description & "  Quitting."
  245.         Exit Sub
  246.     End If
  247.     Set Drs = objApp.Drawings
  248.     If Drs Is Nothing Then
  249.         MsgBox "Bad server.  " & Err.Description & "  Quitting"
  250.         Exit Sub
  251.     End If
  252.     Call Init_FiltersList
  253. End Sub
  254. Private Sub Run_Click()
  255.     On Error GoTo ErrorHandler
  256.     Dim CadFile As String
  257.     Dim CadFileSave As String
  258.     Dim temp As String
  259.     Dim i, b As Integer
  260.     i = 0
  261.     b = File1.ListCount
  262.     If (b = 0) Then
  263.         MsgBox "No .tcw files in source directory"
  264.         Exit Sub
  265.     End If
  266.     While (i < b)
  267.         
  268.        Label3.Caption = File1.List(i) + " file is being converted"
  269.        Label3.Refresh
  270.        
  271.        temp = Right(File1.Path, 1)
  272.        If (temp = "\") Then
  273.            CadFile = File1.Path & File1.List(i)
  274.        Else
  275.            CadFile = File1.Path & "\" & File1.List(i)
  276.        End If
  277.        Set Dr = Drs.Open(CadFile)
  278.        temp = Right(File2.Path, 1)
  279.        
  280.        CadFileSave = Left(File1.List(i), (Len(File1.List(i)) - 4)) ' clip the extesion of the file
  281.        If (temp = "\") Then
  282.            CadFileSave = File2.Path & CadFileSave & Left((Right(Combo2.Text, 5)), 4)
  283.        Else
  284.            CadFileSave = File2.Path & "\" & CadFileSave & Left((Right(Combo2.Text, 5)), 4)
  285.        End If
  286.        Dr.SaveAs (CadFileSave)
  287.        Set Dr = Nothing
  288.        i = i + 1
  289.        File2.Refresh
  290.        NFiles2.Caption = File2.ListCount
  291.        NFiles2.Refresh
  292.     Wend
  293.     Label3.Caption = ""
  294.     Label3.Refresh
  295.    MsgBox "Conversion is complete !"
  296. Exit Sub
  297. ErrorHandler:
  298.     MsgBox Err.Description
  299. End Sub
  300. Public Sub Init_FiltersList()
  301.     Dim n As Long
  302.     Dim Ft As Object 'AddIn
  303.     Dim FtName As String
  304.     Dim i As Long
  305.     i = 0
  306.     Set Ftrs = objApp.Filters
  307.     n = Ftrs.Count
  308.     Combo1.Clear
  309.     Combo2.Clear
  310.     While (i < n)
  311.         Set Ft = Ftrs.Item(i)
  312.         FtName = Ft.FilterString
  313.         FtName = Left(FtName, (Len(FtName) - 8))
  314.         Combo1.AddItem FtName
  315.         Combo2.AddItem FtName
  316.         
  317.         i = i + 1
  318.     Wend
  319.     Combo1.ListIndex = 0
  320.     Combo2.ListIndex = 1
  321.     File1.Pattern = Left((Right(Combo1.Text, 6)), 5)
  322.     File1.Refresh
  323.     NFiles1.Caption = File1.ListCount
  324.     File2.Pattern = Left((Right(Combo2.Text, 6)), 5)
  325.     File2.Refresh
  326.     NFiles2.Caption = File2.ListCount
  327.     Combo1.Refresh
  328.     Combo2.Refresh
  329. End Sub
  330. Private Sub SetupImport_Click()
  331.     MsgBox "Not implemented yet !"
  332. End Sub
  333. Private Sub SetupExport_Click()
  334.     Dim CadFileSave As String
  335.     MsgBox "Not implemented yet !"
  336. End Sub
  337. Sub Timer1_Timer()
  338.     If (CurCombo = True) Then
  339.         If (CurImportFilter <> Combo1.Text) Then
  340.             File1.Pattern = Left((Right(Combo1.Text, 6)), 5)
  341.             File1.Refresh
  342.             NFiles1.Caption = File1.ListCount
  343.         End If
  344.     Else
  345.         If (CurExportFilter <> Combo2.Text) Then
  346.             File2.Pattern = Left((Right(Combo2.Text, 6)), 5)
  347.             File2.Refresh
  348.             NFiles2.Caption = File2.ListCount
  349.         End If
  350.     End If
  351. End Sub
  352.